package com.gitee.somenvm.ninerpgitem.core.resolver

import taboolib.common.LifeCycle
import taboolib.common.platform.Awake
import taboolib.common.platform.function.console
import taboolib.common.platform.function.server
import taboolib.module.chat.colored
import kotlin.reflect.full.createInstance

interface PlaceholderResolver {
    val id: String
    fun resolve(source: String, placeholder: String, context: Context): List<String> // 返回字符串列表

    //还原占位符(傻逼设计不要学
    fun restore(placeholder: String) = "{$id:$placeholder}"
    fun register() {
        Companion.register(this)
    }

    companion object {
        private val resolvers = mutableMapOf<String, PlaceholderResolver>()

        /**
         * 注册解析器
         */
        fun register(resolver: PlaceholderResolver) {
            resolvers[resolver.id] = resolver
            console().sendMessage("&a注册解析器&e>>>&f ${resolver.id}".colored())
        }

        fun getResolver(method: String): PlaceholderResolver? {
            return resolvers[method]
        }
    }
}